//
//  VipSpaceCollectionViewCell.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/5/29.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "VipSpaceCollectionViewCell.h"

static CGFloat titleHeight = 20;
static CGFloat desHeight = 14;

@interface VipSpaceCollectionViewCell()

@property (nonatomic,strong) UIImageView *bgImgView;

@property (nonatomic,strong) UILabel *titleLb;

@property (nonatomic,strong) UILabel *desLb;

@property (nonatomic,strong) UIImageView *goBtn;

@end

@implementation VipSpaceCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self configUI];
    }
    return self;
}
- (void)configUI{
    [self.contentView addSubview:self.bgImgView];
    [self.bgImgView addSubview:self.titleLb];
    [self.bgImgView addSubview:self.desLb];
    [self.bgImgView addSubview:self.goBtn];
//    todo
    _titleLb.text = @"超值月度流量";
    _desLb.text = @"没有WIFI也任性";
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat gap = 5;
    [_bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(gap, gap,gap ,gap));
    }];
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@(gap));
        make.height.equalTo(@(titleHeight));
        make.right.equalTo(_bgImgView).offset(-gap);
    }];
    [_desLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLb);
        make.top.equalTo(_titleLb.mas_bottom).offset(gap);
        make.right.equalTo(_bgImgView).offset(-50);
        make.height.equalTo(@(desHeight));
    }];
    [_goBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLb);
        make.height.equalTo(@20);
        make.width.equalTo(@50);
        make.bottom.equalTo(_bgImgView).offset(-2*gap);
    }];
}
- (UIImageView *)bgImgView{
    if (!_bgImgView) {
        _bgImgView = [UIImageView new];
        _bgImgView.backgroundColor = [UIColor qmui_randomColor];
    }
    return _bgImgView;
}
- (UILabel *)titleLb{
    if (!_titleLb) {
        _titleLb = [UILabel new];
        _titleLb.font = [UIFont systemFontOfSize:15];
        _titleLb.textColor = KcolorTitleBlack;
    }
    return _titleLb;
}
- (UILabel *)desLb{
    if (!_desLb) {
        _desLb = [UILabel new];
        _desLb.font = [UIFont systemFontOfSize:12];
        _desLb.textColor = KcolorTitlGray;
    }
    return _desLb;
}
- (UIImageView *)goBtn{
    if (!_goBtn) {
        _goBtn = [UIImageView new];
        _goBtn.image = UIImageMake(@"goBtn");
    }
    return _goBtn;
}
@end
